package com.zeng.ssm.service.impl;

import com.zeng.ssm.api.IGxpCoreClientService;
import com.zeng.ssm.service.support.trans.GxpConstant;
import com.zeng.ssm.service.support.trans.base.IClientHandler;
import com.zeng.ssm.service.support.trans.base.model.BaseMessage;
import com.zeng.ssm.service.support.trans.client.core.acctNoQuery.model.AcctNoQueryTransComponent;
import com.zeng.ssm.service.support.trans.scanner.TransHandlerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
 * 客户端-核心
 *
 * @author zengwanlin
 * @date 2023-09-04T10:21
 */
@Service
public class GxpCoreClientServiceImpl implements IGxpCoreClientService {

    /**
     * 账号信息查询
     *
     * @param acctNo 账号
     * @return
     */
    @Override
    public BaseMessage acctNoQuery(String acctNo) {
        Assert.hasText(acctNo, "账号不能为空");
        AcctNoQueryTransComponent component = new AcctNoQueryTransComponent();
        component.setContractId(0);
        component.setDetailId(0);
        component.setProductNo("0");
        component.setAcctNo(acctNo);
        IClientHandler clientHandler = TransHandlerFactory.getClientHandler(GxpConstant.SYS_CODE_CORE, GxpConstant.MSG_CODE_CORE_0001);
        clientHandler.handle(component);
        if (!component.isSuccess()) {
            throw new IllegalStateException(component.getRetMsg());
        }
        return component.getRespMessage();
    }

}
